package ctd.util;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;


/**
 * @author houxr
 * @create 2017-02-27 10:52
 **/
public class FileUtil {
    public static String getMd5Code(File file) throws FileNotFoundException {
        FileInputStream fis = new FileInputStream(file);
        String md5 = "";
        try {
            md5 = DigestUtils.md5Hex(fis);
        } catch (IOException e) {
            e.printStackTrace();
        }
        IOUtils.closeQuietly(fis);
        return md5.toUpperCase();
    }
}
